<template>
	<view class="page">
		<view class="topbox">
			<view class="money">
				{{money}}
			</view>
		</view>
		<view class="checkbox">
			<view class="checktitle">
				选择类型
			</view>
			<view class="checkline">
				<view class="itemcheck" @click="selectcheck(3)">
					<view v-if="check==3" class="iconfont icon-xuanzhong act"></view>
					<view v-if="check!=3" class="iconfont icon-weixuanzhong"></view>
					提现到押金
				</view>
				<view class="itemcheck" @click="selectcheck(1)">
					<view v-if="check==1" class="iconfont icon-xuanzhong act"></view>
					<view v-if="check!=1" class="iconfont icon-weixuanzhong"></view>
					提现
				</view>
			</view>
		</view>
		<view class="checkbox">
			<view class="checktitle">
				提现金额
			</view>
			<view class="putline">
				 ￥ <input type="number" placeholder="请输入充值金额" v-model="num" />
				 <view class="btn" @click="allprice">
				 	全部金额
				 </view>
			</view>
		</view>
		<view class="pagebtn" @click="tijiao">
			提交审核
		</view>
	</view>
</template>

<script>
	import {getMemberById,applyWithdraw} from '../../utils/api.js'
	export default {
		data() {
			return {
				money:'',
				check:'1',
				num:''
			}
		},
		onShow() {
			getMemberById().then(res=>{
				this.money=res.data.data.commissionAmount
			})
		},
		methods: {
			tijiao(){
				if(this.num==''){
					uni.showToast({
						title: '请输入充值金额',
						icon:'none',
						duration: 2000
					});
					return
				}
				if(Number(this.money)<Number(this.num)){
									 uni.showToast({
									 	title: '超过返润最大额度',
									 	icon:'none',
									 	duration: 2000
									 });
									 return 
				}
				let p={
					type:this.check,
					amount:this.num
				}
				applyWithdraw(p).then(res=>{
					console.log(res,'这是提现')
					if(res.data.code==200){
						uni.showToast({
						 	title: '已提交待审核',
						 	icon:'none',
						 	duration: 2000
						 });
						setTimeout(()=>{
							uni.navigateBack()	
						},1000)
					}
				})
				
			},
			
			    //全部金额
			allprice(){
				this.num=this.money
			},
			selectcheck(e){
				this.check=e
			},
		}
	}
</script>

<style lang="less" scoped>
   .page{
	   width: 750rpx;
	   box-sizing: border-box;
	   .topbox{
		  background: #FF5C00;
		  width: 100%;
		  height: 300rpx;
		  color: white;
		  text-align: center;
		  box-sizing: border-box;
		  line-height: 270rpx;
		  font-size: 60rpx;
		  font-weight: bold;
	   }
	   .checkbox{
		   width: 100%;
		   height: 150rpx;
		   box-sizing: border-box;
		   padding: 20rpx;
		   margin-top: 30rpx;
		   .checktitle{
			  font-weight: bold; 
		   }
		   .checkline{
			   width: 80%;
			   margin:50rpx auto;
			   display: flex;
			   align-items: center;
			   justify-content: space-between;
			   .itemcheck{
				   display:flex;
				   align-items: center;
				   .iconfont{
					   margin-right: 20rpx;
					   color: gray;
				   }
				   .act{
					   color: #FF5C00;
				   }
			   }
		   }
		   .putline{
			   width: 100%;
			   height: 80rpx;
			   line-height: 80rpx;
			   display: flex;
			   align-items: center;
			   justify-content: space-between;
			   font-size: 50rpx;
			   font-weight: bold;
			   margin-top: 30rpx;
			   border-bottom: 1rpx solid whitesmoke;
			   input{
				   flex: 1;
				   height: 80rpx;
				   padding: 0 20rpx;
			   }
			   .btn{
				   width: 180rpx;
				   height: 80rpx;
				   border-radius: 10rpx;
				   color: white;
                    text-align: center;
					line-height: 80rpx;
					background-color: #FF5C00;
					font-size: 32rpx;
					
			   }
		   }
	   }
	   .pagebtn{
		   width: 80%;
		  height: 80rpx;
		  border-radius: 40rpx;
		  color: white;
		   text-align: center;
		  					line-height: 80rpx;
		  					background-color: #FF5C00;
		  					font-size: 32rpx;
		   margin:300rpx auto;
	   }
   }
</style>
